﻿using System;
using EzDesk.Apps.ServiceImpl.Staff;
using EzDesk.EzAppApi.Utility;
using NUnit.Framework;

namespace EzDesk.Apps.UnitTest
{
    public class StaffServiceContext : StaffContextBase<StaffService>
    {
        public StaffServiceContext()
        {
            _ezApiClient = new Mock_EzApiClient();
            //_staffInfoRepository = new Mock_ContactInfoRepository();
        }

        public override StaffService Service
        {
            get
            {
                initialMockData();

                return new StaffService();
            }
        }

        private void initialMockData()
        {

        }
    }



    [TestFixture]
    public class StaffInfoFixture
    {
        [Test]
        public void Test_查看一个员工的用户StaffInfo()
        {
            var context = new StaffServiceContext();

            var result = context.Service.GetContactInfoByUserId(Mock_EzApiClient.GetMockUserId("杨裕欣")).Result;

            Assert.AreEqual(result.QqNumber, "47368554");
            Assert.AreEqual(result.MobileNo, "18602109196");
            Assert.AreEqual(result.MainEmail, "yayx@21cn.com");
        }

        [Test]
        public void Test_查看一个不存在的员工的用户StaffInfo()
        {
            var context = new StaffServiceContext();

            var result = context.Service.GetContactInfoByUserId(new Guid());

            Assert.AreEqual(result, null);
        }

        [Test]
        public void Test_查看多个员工的StaffInfo()
        {
            // 因为还没实现Mock_EzApiClient中的GetUserByMemberstring，因此暂时不测试这个，基本上是不会出错的
            throw new NotImplementedException();
        }

        [Test]
        public void Test_修改一个员工的某项StaffInfo()
        {
            var context = new StaffServiceContext();

            var staffInfo = context.Service.GetContactInfoByUserId(Mock_EzApiClient.GetMockUserId("杨裕欣")).Result;
            // 修改信息
            staffInfo.MainEmail = "yannicyang@gmail.com";

            context.Service.UpdateContactInfo(staffInfo);

            staffInfo = context.Service.GetContactInfoByUserId(Mock_EzApiClient.GetMockUserId("杨裕欣")).Result;
            Assert.AreEqual(staffInfo.MainEmail, "yannicyang@gmail.com");
        }
    }
}